<template>
    <div class="wrapper">
        <div class="banner">
            <img src="http://file.rzkeji.com/web/dang/question_banner.png">
        </div>
        <div class="content">
            <!-- <div class="random" v-if="type == 'random'">
              <div class="question-title">{{questionRandom.name}}</div>
              <div class="question-reset" @click="getRandomQuestion">重选题库</div>
              <div class="question-ok" @click="pushToStart(questionRandom.id)">确定</div>
            </div> -->
            <div class="question-list">
              <div class="question-list-item" v-for="(item,index) in questionList" :key="index" @click="pushToStart(item.id)">{{item.name}}</div>
            </div>
        </div>
    </div>
</template>

<script>
    /**
	 * @description 答题选择页面2
	 */
    export default {
      data(){
        return{
            // type: this.$route.params.type,
            questionList: [],
            questionRandom:{},
            // randomIndex: null,//只有两个题库，索引减少重复率
            // randomFlag: true,//只有两个题库，开关减少重复率
        }
      },
      mounted(){
        this.getQuestionLis();
      },
      methods:{
        async getQuestionLis(){
          let res = await this.$api.getQuestionsPackageList();
          if(res.data.level == "success"){
            this.questionList = res.data.data;
            // this.getRandomQuestion();
          }
        },
        //随机选题
        // getRandomQuestion(){
        //   if(this.randomFlag){
        //     this.randomFlag = false;
        //     this.index = Math.round(Math.random());
        //   }else{
        //     if(this.index == 0){
        //       this.index = 1;
        //     }else{
        //       this.index = 0;
        //     }
        //   }
        //   this.questionRandom = this.questionList[this.index]
        // },
        //路由跳转
        pushToStart(id){
			console.log(id)
			uni.navigateTo({
				url:`/pages/questionStart/questionStart?id=${id}`
			})
        }
      }
    }
</script>

<style scoped>
    .wrapper{
      width: 100%;
      min-height: 100%;
      background-color: #d40c14;
    }
     .banner{
        width: 100%;
    }

    .banner img{
        width: 100%;
		height: 480rpx;
    }

    .content{
        width: 100%;
    }
    .content .random,
    .content .question-list{
      width: 85%;
      margin: 0 auto;
      height: calc(100vh - 480rpx);
      overflow: auto;
    }

    /* .content .random .question-title{
        text-align: center;
        font-size: 0.533333rem;
        width: 8.333333rem;
        padding: 0.266667rem;
        color: white;
    }

    .content .random .question-reset,.content .question-ok{
        margin-top:80px;
        background-color: orange;
        text-align: center;
        font-size: 0.533333rem;
        width: 10.333333rem;
        padding: 0.266667rem;
        border-radius: 0.133333rem;
        color: white;
        border: none;
    } */

    .question-list-item{
      text-align: center;
      font-size: 14px;
      width: 500rpx;
      padding: 20rpx;
      margin: 50rpx auto;
      color: white;
      border: 2rpx solid white;
    }
    .question-list-item.active{
      color: rgb(238, 195, 115);
      border: 2px solid rgb(238, 195, 115);
    }
</style>
